import React, { Component } from "react";
import "../css/InputBox.css";
import eventEmitter from "../events"

class InputBox extends React.Component {
    constructor(props) {
      super(props);
     
      this.state = {
       
      };
    };
    render() {
      return (
        <div className="input_container">
             <input type="text" ref="input"/>
             <button onClick={()=>{
                 let value =this.refs.input.value;
                 if(value.length===0){
                     alert('输入内容不能为空');
                     return
                 }
                 var date =new Date();
                 var dateStr=`${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日${date.getHours()}时${date.getMinutes()}分`
                 var message={
                     content:value,
                     date:dateStr,
                 }
                 eventEmitter.emit('sendMessageToBoard',message)
             }}>提交</button>
        </div>
      
      );
    }
  }
export default InputBox;
